package cn.itrigger.dynamic.sql.render;

import cn.itrigger.dynamic.sql.structure.BindableColumn;

/**
 * @author admin
 * @date 2018/9/21
 **/
public class MyBatis3RenderingStrategy extends RenderingStrategy {
    @Override
    public String getFormattedJdbcPlaceholder(BindableColumn<?> column, String prefix, String parameterName) {
        return "#{"
                + prefix
                + "."
                + parameterName
                + renderJdbcType(column)
                + "}";
    }

    private String renderJdbcType(BindableColumn<?> column) {
        return column.jdbcType().map(jdbcType -> ",jdbcType=" + jdbcType.getName()).orElse("");
    }
}
